<?php

/**
 * Destination filter form base class.
 *
 * @package    mercure
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseDestinationFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idloc_lieudepart'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Localisation_3'), 'add_empty' => true)),
      'idloc_lieuarrivee' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Localisation'), 'add_empty' => true)),
      'idpriseencharge'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Transfert'), 'add_empty' => true)),
      'heuredepart'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'heurearrivée'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'numordre'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'idloc_lieudepart'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Localisation_3'), 'column' => 'idloc')),
      'idloc_lieuarrivee' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Localisation'), 'column' => 'idloc')),
      'idpriseencharge'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Transfert'), 'column' => 'idpriseencharge')),
      'heuredepart'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'heurearrivée'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'numordre'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('destination_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Destination';
  }

  public function getFields()
  {
    return array(
      'iddestination'     => 'Number',
      'idloc_lieudepart'  => 'ForeignKey',
      'idloc_lieuarrivee' => 'ForeignKey',
      'idpriseencharge'   => 'ForeignKey',
      'heuredepart'       => 'Date',
      'heurearrivée'     => 'Date',
      'numordre'          => 'Number',
    );
  }
}
